package org.locker.netty.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.locker.netty.dto.command.*;
import org.locker.netty.dto.reply.CommonReply;
import org.locker.netty.dto.reply.GetSimInfoReply;
import org.locker.netty.dto.reply.QueryApkLastVersionD2sReply;
import org.locker.netty.dto.reply.SynchronousGridListReply;

@Getter
@AllArgsConstructor
public enum MessageEnum{
    /**************************服务端--->主动发送-->设备**********************************/
    //重启设备
    RESTART_DEVICE("RESTART_DEVICE", CommonCommand.class),
    RESTART_DEVICE_REPLY("RESTART_DEVICE_REPLY", CommonReply.class),

    //设置设备基础信息(包括UI,格子信息,收费计划)
    SET_DEVICE_POSITION("SET_DEVICE_POSITION", SetDevicePosition.class),
    SET_DEVICE_POSITION_REPLY("SET_DEVICE_POSITION_REPLY", CommonReply.class),

    //心跳
    HEART("HEART", CommonReply.class),



    //全部开锁
    CONTROL_OPEN_ALL("CONTROL_OPEN_ALL", CommonCommand.class),
    CONTROL_OPEN_ALL_REPLY("CONTROL_OPEN_ALL_REPLY", CommonReply.class),

    //同步格子锁状态
    SYNCHRONOUS_GRID_LIST("SYNCHRONOUS_GRID_LIST", CommonCommand.class),
    SYNCHRONOUS_GRID_LIST_REPLY("SYNCHRONOUS_GRID_LIST_REPLY", SynchronousGridListReply.class),

    //批量设置格子状态
    BATCH_SET_GRID("BATCH_SET_GRID", BatchSetGrid.class),
    BATCH_SET_GRID_REPLY("BATCH_SET_GRID_REPLY", CommonReply.class),
    //设置格子状态
    SET_GRID("SET_GRID", DeviceSingleLockStatusReply.class),
    SET_GRID_REPLY("SET_GRID_REPLY", CommonReply.class),

    //设备信息同步
    DEVICE_COMMON_INFO_SYNC("DEVICE_COMMON_INFO_SYNC", DeviceCommonInfoSync.class),
    DEVICE_COMMON_INFO_SYNC_REPLY("DEVICE_COMMON_INFO_SYNC_REPLY", CommonReply.class),


    //控制蓝牙开关
    CONTROL_BLE_SWITCH("CONTROL_BLE_SWITCH", ControlBleSwitch.class),
    CONTROL_BLE_SWITCH_REPLY("CONTROL_BLE_SWITCH_REPLY", CommonReply.class),


    //更新蓝牙版本
    UPGRADE_BLE("UPGRADE_BLE", UpgradeBle.class),
    UPGRADE_BLE_REPLY("UPGRADE_BLE_REPLY", CommonReply.class),


    //PUSH 推送订单--->还需要推送 开锁
    PUSH_ORDER("PUSH_ORDER", PushOrder.class),
    PUSH_ORDER_REPLY("PUSH_ORDER_REPLY", CommonReply.class),

    //开锁
    CONTROL_OPEN("CONTROL_OPEN", ControlOpen.class),
    CONTROL_OPEN_REPLY("CONTROL_OPEN_REPLY", CommonReply.class),


    //订单结束
    PUSH_ORDER_FINISH("PUSH_ORDER_FINISH", PushOrder.class),
    PUSH_ORDER_FINISH_REPLY("PUSH_ORDER_FINISH_REPLY", CommonReply.class),


    //同步所有订单信息
    ORDER_LIST_SYNC("ORDER_LIST_SYNC", OrderListSync.class),

    ORDER_LIST_SYNC_REPLY("ORDER_LIST_SYNC_REPLY", CommonReply.class),

    //获取设备SIM卡信息
    GET_SIM_INFO("GET_SIM_INFO", CommonCommand.class),
    GET_SIM_INFO_REPLY("GET_SIM_INFO_REPLY", GetSimInfoReply.class),

    //进入设备管理后台
    ADMIN_EXEC("ADMIN_EXEC", CommonCommand.class),
    ADMIN_EXEC_REPLY("ADMIN_EXEC_REPLY", CommonReply.class),

    //设置管理账号
    MODIFY_ADMIN_ACCOUNT("MODIFY_ADMIN_ACCOUNT", ModifyAdminAccount.class),
    MODIFY_ADMIN_ACCOUNT_REPLY("MODIFY_ADMIN_ACCOUNT_REPLY", CommonReply.class),

    //上传设备日志
    UPLOAD_DEVICE_LOG("UPLOAD_DEVICE_LOG", CommonCommand.class),
    UPLOAD_DEVICE_LOG_REPLY("UPLOAD_DEVICE_LOG_REPLY", CommonReply.class),

    //删除设备信息
    DELETED_DEVICE_LOG("DELETED_DEVICE_LOG", CommonCommand.class),
    DELETED_DEVICE_LOG_REPLY("DELETED_DEVICE_LOG_REPLY", CommonReply.class),

    //获取单个锁信息
    DEVICE_SINGLE_LOCK_STATUS("DEVICE_SINGLE_LOCK_STATUS", DeviceSingleLockStatus.class),
    //上锁信息服务端回复
    DEVICE_SINGLE_LOCK_STATUS_REPLY("DEVICE_SINGLE_LOCK_STATUS_REPLY", DeviceSingleLockStatusReply.class),
    /**************************设备--->主动发送-->服务端**********************************/
    //离线订单上报
    OFFLINE_ORDER_PUSH_SYNC_D2S("OFFLINE_ORDER_PUSH_SYNC_D2S", PushOrder.class),

    //服务端回复
    OFFLINE_ORDER_PUSH_SYNC_D2S_REPLY("OFFLINE_ORDER_PUSH_SYNC_D2S_REPLY", PushOrder.class),

    //获取最新版本
    QUERY_APK_LAST_VERSION_D2S("QUERY_APK_LAST_VERSION_D2S", QueryApkLastVersionD2s.class),
    //获取最新版本返回
    QUERY_APK_LAST_VERSION_D2S_REPLY("QUERY_APK_LAST_VERSION_D2S_REPLY", QueryApkLastVersionD2sReply.class),

    //同步所有订单
    QUERY_ORDER_LIST_SYNC_D2S("QUERY_ORDER_LIST_SYNC_D2S", CommonCommand.class),

    //同步所有订单返回。OrderListSync.class
    QUERY_ORDER_LIST_SYNC_D2S_REPLY("QUERY_ORDER_LIST_SYNC_D2S_REPLY", OrderListSync.class),


    //开锁回复指令
    DEVICE_CONTROL_OPEN_RESULT_D2S("DEVICE_CONTROL_OPEN_RESULT_D2S", ControlOpenResult.class),



    LOGIN_D2S("LOGIN_D2S", LoginDevice.class),
    LOGIN_D2S_REPLY("LOGIN_D2S_REPLY", CommonReply.class),


    ;


    private String code;

    private Class<?> clazz;


    public static MessageEnum valuesOf(String code) {
        MessageEnum[] values = MessageEnum.values();
        for (MessageEnum value : values) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return HEART;
    }
}
